#include<bits/stdc++.h>

using namespace std;

#ifndef DEBUG
#define NDEBUG
#endif

inline int char2int(const char &c){
    return c-'0';
}
inline bool is_num(char c){
    return c >= '0' && c <= '9';
}

map<char,int>op_priority={{'+',0}, {'-',0}, {'x',1}, {'/',1}};

stack<char> op_stack;
stack<int> num_stack;

inline void caculate(){
    int b = num_stack.top();
    num_stack.pop();
    int a = num_stack.top();//a, b后出栈者在前
    num_stack.pop();
    char op = op_stack.top();
    op_stack.pop();

    switch (op)
    {
    case '+'/* constant-expression */:
        num_stack.push(a+b);
        break;
    case '-':
        num_stack.push(a-b);
        break;
    case 'x':
        num_stack.push(a*b);
        break;
    case '/':
        num_stack.push(a/b);
        break;
    }
}



int main(){
    int n,s;
    string expression;
    cin >> n;
    getchar();
    for(int i=0;i<n;i++){        
        s=0;
        getline(cin,expression);        
        num_stack.push(char2int(expression[0]));
        for(int j=1;j < expression.length();j+=2){            
            char op = expression[j];
            if(!op_stack.empty() && op_priority[op] <= op_priority[op_stack.top()]){
                caculate();                
            }
            op_stack.push(op);
            num_stack.push(char2int(expression[j+1]));  
        }
        while(!op_stack.empty()){
            caculate();
        }        
        if(num_stack.top() == 24){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        num_stack.pop();

    }
    return 0;
}